<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>父母必修课</title>
		<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/app.css" />
		<link rel="stylesheet" type="text/css" href="../../css/utils.css" />
		<style>
			#serachbxk{
				position: fixed;
				width: 100%;
				height: 40px;
				top: 10px;
				background-color: #fafafa;
			}
		</style>
	</head>
	<body>
		<div id="serachbxk" style="">
			<input type="search" placeholder="Search" style="height: 30px; background-color: white; font-size: 17px;"/>
		</div>
		<div class="mui-content">
			<div id="rfcpostsComp" class="mui-scroll-wrapper" style="height: 92%; top: 60px;">
				<div class="mui-scroll">
					<div id="postsComplst">
						<!--
                        	作者：xuzhao_deng@sina.com
                        	时间：2017-01-06
                        	描述：好文列表数据展示区
                        -->
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/utils/http.utils.js"></script>
	<script src="../../js/bus/pubfun.js"></script>
	<script>
		var $currpage = 0;
		var $orgId = localStorage.getItem("wxfwid");
		mui.init({
			pullRefresh: {
				container: "#rfcpostsComp",
				up: {
					height: 20,
					auto: true, 
					deceleration: 0.0006 ,
					contentrefresh : "加载中...",
					contentnomore:'没有更多数据了',
					callback: postsCompLstDat
				}
			}
		});
		
		function postsCompLstDat(){
			getPostsCompLstDat(8, $currpage);
		}
		
		//
		function getPostsCompLstDat($psize, $cpage){
			mui.ajax({
				url : $request_url.getArticleLst,
				type : "get",
				headers: {
					"Authorization": $headers_authorization
				},
				dataType : "json",
				data : {
					typeCode : "SGBX",
					orgId : $orgId,
					recommend : "",
					rows : $psize,
					page : $cpage
				}, 
				success : function(dat){
					if(dat.code == 0){
						var $result = dat.result;
						if($result != null && $result != ""){
							$currpage ++;
							mui("#rfcpostsComp").pullRefresh().endPullupToRefresh(false);
							var $resDoc = document.getElementById("postsComplst");
							for(var i = 0; i < $result.length; i ++){
								var $div = document.createElement("div");
								$div.innerHTML = postsComplstTem($result[i], i);
								$resDoc.appendChild($div);
							}
						} else {
							mui("#rfcpostsComp").pullRefresh().endPullupToRefresh(true);
						}
					} else {
						mui.toast(dat.message);
						mui("#rfcpostsComp").pullRefresh().endPullupToRefresh(true);
						return;
					}
				}, error : function(err){
					mui.toast("服务繁忙...");
					mui("#rfcpostsComp").pullRefresh().endPullupToRefresh(true);
					return;
				}
			});
		}
		
		function postsComplstTem($info, $num){
			var $author = "345教育";
			if($info.author != null && $info.author != ""){
				$author = $info.author;
			}
			var $postsCompHtml =  
			'<a href="artdetails.html?artid='+ $info.id +'">'
			+	'<div style="margin-left: 10px; margin-top:5px; margin-right:10px;">'
			+		'<span style="color: #303030; font-size: 17px;">'+ $info.title +'</span>'
			+		'<span style="color: #909090; font-size: 15px; display: block; margin-top:2px">'+ $info.contentAbstract +'</span>'
			+		'<span style="color: #909090; font-size: 14px; display: block; margin-top:2px"><img src="'+ $info.thumbnail +'" style="width:100%;"></span>'
			+		'<!--<span style="display: block; color: #616161; font-size: 13px; margin-top: 10px;">推荐人:张三丰</span>-->'
			+		'<span style="display: block; color: #909090; font-size: 13px; margin-top: 5px;">'+ $author +'</span>'
			+		'<div style="margin-top: 10px;">'
			+			'<span style="color: #909090; font-size: 13px; float: left;"><img src="img/read.png" style="width: 16px;">&nbsp;'+ $info.readCount +'</span>'
			+			'<span style="display: block; color: #909090; font-size: 13px; float: right; margin-right:10px;">'+ stringConTime($info.publishDate, "ymd") +'</span>'
			+		'</div>'
			+	'</div>'
			+'</a>'
			+'<div style="margin-top: 5px;">'
			+	'<hr class="levline" />	'
			+'</div>';
			return $postsCompHtml;
		}
		
		/**
		 * 绑定事件
		 */
		mui("#postsComplst").on("tap", "a", function(){
			mui.openWindow({
				url : this.href
			});
		});
	</script>
</html>
